import numpy as np
import torch

data_numpy = np.array([2, 3, 4])
# 将 numpy 数组转换为张量类型
# 1. from_numpy
# 2. torch.tensor(ndarray)
data_tensor = torch.from_numpy(data_numpy)
print(data_tensor)
print(data_numpy)


data_numpy = np.array([2, 3, 4])
data_tensor = torch.tensor(data_numpy)
print(data_tensor)
print(data_numpy)